﻿<UserControl x:Class="SubtitleTools.Shell.SyncView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:SubtitleTools.Infrastructure.ViewModels;assembly=SubtitleTools.Infrastructure"
             mc:Ignorable="d" Background="#FF393939" FontFamily="Tahoma"
             Name="ThisSyncView"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <vm:SyncViewModel x:Key="vmSyncViewModel" />
    </UserControl.Resources>
    <Grid DataContext="{Binding Source={StaticResource vmSyncViewModel}}"
          FocusManager.FocusedElement="{Binding ElementName=txtSeconds}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <GroupBox Header="Shift direction" Margin="3" Grid.Column="0">
                <StackPanel VerticalAlignment="Center" HorizontalAlignment="Center" Margin="3">
                    <ListBox x:Name="RadioButtonList" 
                             IsSynchronizedWithCurrentItem="True"
                             SelectedIndex="{Binding SyncModelData.AddIndex}"
                             BorderThickness="0" Background="{x:Null}">       
                        <ListBoxItem IsSelected="{Binding IsChecked, ElementName=RadioButton1, Mode=OneWay}">
                            <RadioButton x:Name="RadioButton1" GroupName="Group">Add</RadioButton>
                        </ListBoxItem>
                        <ListBoxItem IsSelected="{Binding IsChecked, ElementName=RadioButton2, Mode=OneWay}">
                            <RadioButton x:Name="RadioButton2" GroupName="Group">Remove</RadioButton>
                        </ListBoxItem>
                        <ListBox.ItemContainerStyle>
                            <Style TargetType="{x:Type ListBoxItem}">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ListBoxItem}">
                                            <ContentPresenter/>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>
                        </ListBox.ItemContainerStyle>
                    </ListBox>
                </StackPanel>
            </GroupBox>
            <GroupBox Margin="3" Header="Amount" Grid.Column="1">
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" Grid.Column="0" Text="Hours" Margin="3" />
                    <TextBox Grid.Row="1" Grid.Column="0"
                                 Text="{Binding SyncModelData.Hour}"
                                 Margin="3" Width="40" />

                    <TextBlock Grid.Row="0" Text="Minutes" Grid.Column="1" Margin="3"/>
                    <TextBox Grid.Column="1" Grid.Row="1" 
                                 Text="{Binding SyncModelData.Minutes}"
                                 Margin="3" Width="40" />

                    <TextBlock Grid.Row="0" Text="Seconds" Grid.Column="2" Margin="3"/>
                    <TextBox Grid.Column="2" Grid.Row="1" Name="txtSeconds"
                                 Text="{Binding SyncModelData.Seconds}"
                                 Margin="3" Width="40" />

                    <TextBlock Grid.Row="0" Text="Ms." Grid.Column="3" Margin="3"/>
                    <TextBox Grid.Column="3" Grid.Row="1" 
                                 Text="{Binding SyncModelData.Milliseconds}"
                                 Margin="3" Width="40" />
                </Grid>
            </GroupBox>
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
            <Button Content="Apply" 
                Command="{Binding DoSync}"
                CommandParameter="{Binding ElementName=ThisSyncView, Path=FilePath}"
                Margin="3" Height="25" Width="60" />
            <Button Content="Cancel" 
                    Command="{Binding DoCloseSyncView}"
                    Margin="3" Width="60"/>
        </StackPanel>
    </Grid>
</UserControl>
